package com.luocj.muke.demo.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.luocj.muke.demo.R;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.Holder> {
    private Context mContext;

    public MyAdapter(Context context) {
        this.mContext = context;
    }

    @NonNull
    @Override
    public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(mContext).inflate(R.layout.item_text, parent, false);
        Holder holder = new Holder(inflate);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int position) {
        holder.textview.setText( "" + position);
    }

    @Override
    public int getItemCount() {
        return 30;
    }

    public class Holder extends RecyclerView.ViewHolder {
        TextView textview;

        public Holder(View itemView) {
            super(itemView);
            textview = itemView.findViewById(R.id.tv_text);
        }
    }
}
